﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="main.aspx.cs" Inherits="main" %>

<%@ Register src="UserControls/Manager/LeftMenu.ascx" tagname="LeftMenu" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>认证中心后台</title>
    <link href="/themes/default/css/main.css" rel="stylesheet" type="text/css" /> 
    <link href="/themes/default/css/treestyle.css" rel="stylesheet" type="text/css" />
    <link href="/themes/default/css/layer.css" rel="stylesheet" type="text/css" />
    <link href="/themes/default/css/item.css" rel="stylesheet" type="text/css" />
    <script src="/js/common/jquery1.6.1.min.js" type="text/javascript"></script>
    <style type="text/css">
    .DropApp{width:100px;}
    </style>   
</head>
<body>
<form id="form1" runat="server">

<div id="header"><%--头部--%>
    <div id="tool">
         <div id="tool-l"></div>
         <div id="tool-m">
            <div id="tool-loog"></div>
            <div id="nav">
                 <div class="system"></div> 
                 <div class="alter"><a href="javascript:;" onclick="test(); return false"><img src="/themes/default/images/main_07.gif" id="Image1" onmouseover="MM_swapImage('Image1','','themes/default/images/main_07_1.gif',1)" onmouseout="MM_swapImgRestore()" alt="" /></a></div>
                 <div class="user"><img src="/themes/default/images/main_08.gif" alt=""  /></div>
                 <div class="logo"></div>
               <%--  <div class="homepage"><img src="/themes/default/images/main_10.gif"  alt=""  /></div>
                 <div class="recoil"><img src="/themes/default/images/main_11.gif" alt=""  /></div>
                 <div class="onward"><img src="/themes/default/images/main_12.gif"  alt=""  /></div>
                 <div class="renovate"><a href="javascript:;" onclick="ReLoad()"><img src="/themes/default/images/main_13.gif" /></a></div>--%>
                 <div class="toquit"><a href="/Logout.aspx" onclick = "return confirm('确认退出？')" ><img src="/themes/default/images/main_14.gif" id="Image7" onmouseover="MM_swapImage('Image7','','themes/default/images/main_14_1.gif',1)" onmouseout="MM_swapImgRestore()" alt=""  /></a></div>
                 <div class="rim"></div>
            </div>
         </div>
         <div id="tool-r"></div> 
    </div>
    <div id="sub-nav"><%--导航--%>
        <div id="sub-nav-l"></div>
        <ul id="sub-nav-m">
            <li><asp:LinkButton runat="server" ID="ClearCache" Text="清空缓存"  onclick="ClearCache_Click"></asp:LinkButton></li>
        </ul>
        <div id="sub-nav-r">
            <img alt ="" src="/themes/default/images/user.gif" />
            <div id="sub-nav-user">欢迎你:<%=UserTicket.UserName %></div>
        </div>
    </div>
</div>
<div id="main"><%--内容主体--%>
    <div id="main-left"><%--内容左边--%>
        <div id="menu">
            <div id="menutitle" class="title"><span class="treeTitle">菜单</span></div>
            <div id="menu-conent"><%--菜单--%>
                <uc1:LeftMenu ID="LeftMenu1" runat="server" />
            </div>
            <div id="copyright">版本2012 V1.1</div>
        </div>
         <div id="switch-point"><img src="/themes/default/images/main/main_41.gif" id="img" width="9" height="52" alt="关闭/打开左栏" onclick="switchSysBar()" /></div>    
    </div>
    <div id="main-right"><%--内容右边--%>
        <div id="r-top">
            <div id="r-top-l"></div>
            <div id="r-top-r"></div>
        </div>
        <div id="conent"><%--右边主体内容--%>
            <iframe id="mainiframe" frameborder="0" src="/VersionLog/Version.aspx" name="mainiframe" width="100%" style="overflow:auto">
            </iframe>  
        </div>
        <div id="r-foot">
            <div id="r-foot-l"></div>
            <div id="r-foot-r"></div>
        </div>
    </div>
</div>

<div id="divLayer" style="display:none; z-index:999">
            <div class="cont">
                <div class="purshasTextB">
                <table>
                   <tr>
                     <td style="width:50">用户名：</td>
                     <td style="border-left:5"><input style="width:200px" id="txtUserName" type="text" value="<%=UserTicket.UserName %>" readonly="readonly" /></td>
                   </tr>
                   <tr>
                     <td style="width:50">旧密码：</td>
                     <td style="border-left:5"><input id="txtOldPassword"  style="width:200px;" maxlength="25" type="password" onblur="javascript:valdata(this);"  /></td>
                     
                   </tr>
                   <tr>
                     <td style="width:50"> 新密码：</td>
                     <td style="border-left:5"><input id="txtNewPassword"  style="width:200px;" maxlength="25" type="password" onblur="javascript:valdatepwdlength(this);"  /></td>
                      
                   </tr>
                   <tr>
                     <td style="width:50">确认密码：</td>
                     <td style="border-left:5"><input id="txtConfirmPassword"  style="width:200px;" maxlength="25" type="password" onblur="javascript:validatepwdagine(this);"  /></td>
                      
                   </tr>
                   <tr><td colspan="2" valign="middle"><span id="confirminfo" style="font-size:5; color:Red"></span>
                       <input type="hidden" id="hideUserID" value="<%=UserTicket.UserID %>" /> 
                       </td></tr>
                </table>
                </div>
            </div>
            <div  align="center">
               <%-- <a href='javascript:changepwd();' id="sure" class='butYellow' >确 定</a>--%>
                <asp:Button ID="btn" Text="确 定" runat="server" Width="100px" CssClass="btn" OnClientClick="return changepwd();" />
                <input type="hidden" id="HidBool" value="" />
            </div>
</div>
    <script src="/js/mainform/main.js" type="text/javascript"></script>
    <script src="/js/mainform/base.js" type="text/javascript"></script>
    <script type="text/javascript">
        function test() {
            $Layer.Reset();
            $Layer.IsBack = false;
            $Layer.IsFooter = false;
            $Layer.Width = 320;
            $Layer.Title = "修改密码";
            $Layer.CloseText = "关 闭";
            $Layer.Content = $("#divLayer").html();
            $Layer.IsConfirm = true;
            $Layer.Confirm.Text = "确 定";
            $Layer.Confirm.Event = ""
            $Layer.Open();
        }

        function valdata(obj) {
            var str = obj.value;
            $("#HidBool").val("");

            if (str.toString().length > 25) {
                document.getElementById("confirminfo").innerHTML = "用户密码长度不得超过25，请重新输入！";
                //obj.value = "";
                $("#HidBool").val("false");
                return false;
            }
            else {

                var temppwd = $("#txtOldPassword").val();
                var userid = $("#hideUserID").val();
                $("#confirminfo").html("");
                $.getJSON("/handlers/ChangePwd.ashx", { temppwd: temppwd, userid: userid, state: 0 }, function (data) {
                    $.each(data.contents, function (i, item) {

                        if (item.Value != "true") {
                            $("#confirminfo").html("用户密码输入不正确，请重新输入");
                            $("#txtOldPassword").val("");
                            //$("#txtOldPassword").focus().select();
                            $("#HidBool").val("false");
                            return false;

                        }
                        else {
                            $("#HidBool").val("");
                            return;
                        }

                    });
                });

            }

        }

        function validatepwdagine(obj) {
            var str = obj.value;

            $("#confirminfo").html("");
            $("#HidBool").val("");
            if (str.toString().length > 25) {
                document.getElementById("confirminfo").innerHTML = "用户密码长度不得超过25，请重新输入！";
                //obj.value = "";
                //obj.focus().select();
                $("#HidBool").val("false");
                return false;
            }

            if ($("#txtConfirmPassword").val() != $("#txtNewPassword").val()) {
                $("#confirminfo").html("用户新密码输入不一致，请重新输入");
                //obj.value = "";
                //$("#txtConfirmPassword").focus().select();
                $("#HidBool").val("false");
                return false;
            }
            valdatepwdlength(obj);
        }

        function valdatepwdlength(obj) {
            var str = obj.value;

            $("#confirminfo").html("");
            $("#HidBool").val("");
            if (str.toString().length > 25) {
                document.getElementById("confirminfo").innerHTML = "用户密码长度不得超过25，请重新输入！";
                obj.value = "";
                //obj.focus().select();
                $("#HidBool").val("false");
                return false;
            }

            var reg = /^\d+(\.\d+)?$/;
            if (reg.test(str)) {
                document.getElementById("confirminfo").innerHTML = "纯数字密码不安全，请修改为字母+数字的组合！";
                //obj.value = "";
                $("#HidBool").val("false");
                return false;
            }
            var regtwo = /^[A-Za-z]+$/;
            if (regtwo.test(str)) {
                document.getElementById("confirminfo").innerHTML = "纯字母密码不安全，请修改为字母+数字的组合！";
                //obj.value = "";
                $("#HidBool").val("false");
                return false;
            }
        }

        function changepwd() {
            var bool = $("#HidBool").val();
            //alert(bool);
            if (bool == "false") {
                return false;
            }
            else {
                var userid = $("#hideUserID").val();
                var newuserpwd = $("#txtNewPassword").val();

                if ($("#txtOldPassword").val().length < 1) {
                    $("#confirminfo").html("请输入密码！");
                    return false;
                } else if (newuserpwd.length < 1) {
                    $("#confirminfo").html("请输入新密码！");
                    return false;
                } else if ($("#txtConfirmPassword").val().length < 1) {
                    $("#confirminfo").html("请输入确认密码！");
                    return false;
                } else if ($("#txtConfirmPassword").val() != $("#txtNewPassword").val()) {
                    $("#confirminfo").html("用户新密码输入不一致，请重新输入");
                    return false;
                } else {



                    $.getJSON("/handlers/ChangePwd.ashx", { temppwd: newuserpwd, userid: userid, state: 1 }, function () {

                        $("#txtOldPassword").val("");
                        $("#txtNewPassword").val("");
                        $("#txtConfirmPassword").val("");
                        alert("修改完毕！");


                    });

                }
            }

        }
    </script>
</form>
</body>
</html>
